from fastapi import Path, Query
from fastapi.requests import Request

from service.captcha import CaptchaService


class CaptchaController:

    @classmethod
    async def image_captcha(cls, request: Request, uuid: str):
        return await CaptchaService.image_captcha(request, uuid)

    @classmethod
    async def sms_captcha(cls, request: Request, mobile: str = Path(..., max_length=11, min_length=11, regex=r'^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$'),
                          image_captcha: str = Query(...), image_captcha_id: str = Query(...)):
        return await CaptchaService.sms_captcha(request, mobile,
                                                image_captcha, image_captcha_id)

    @classmethod
    async def send_email(cls, request: Request, email: str):
        return CaptchaService.send_email(request, email)
